<template>
	<div class="nearby">
		<h3 class="nearby_title">附近店铺</h3>
		<router-link :to="`/shop/${item._id}`" v-for="item in nearbyList" :key="item._id">
			<ShopInfo :item="item" />
		</router-link>


	</div>
</template>

<script>
	import { ref } from 'vue'
	import { get } from '../../utils/request.js'
	import ShopInfo from '../../components/shopInfo.vue'

	export default {
		name: 'Nearby',
		components: {
			ShopInfo
		},
		setup() {
			// 创建对象
			const nearbyList = ref([]);
			// 存放数据
			const getnl = async () => {
				const result = await get('/api/shop')
				if (result?.errno === 0) {
					nearbyList.value = result.data
				}

			}
			// 调用函数
			getnl()

			return {
				nearbyList
			}
		}
	}
</script>

<style lang="scss" scoped>
	.nearby {
		&_title {
			margin: .16rem 0 .02rem 0;
			font-size: .18rem;
			color: #333333;
		}

		a {
			text-decoration: none;
		}

	}
</style>
